<!-- examineAnswerSheet 答卷审核 -->
<template>
  <div class="content">
    <el-form v-loading="formLoading" class="page-form examine" :model="examinationRecordData" :rules="rules" ref="examineAnswerSheetForm"
             size="medium" label-width="120px">
      <el-form-item label="试卷名称：" prop="title">
        <div>{{examinationRecordData.title}}</div>
      </el-form-item>
      <el-form-item label="考试开始时间：" prop="topicScore">
        <div>{{examinationRecordData.startTime | glbTimeFormat}}</div>
      </el-form-item>
      <el-form-item label="考试结束时间：" prop="topicScore">
        <div>{{examinationRecordData.endTime | glbTimeFormat}}</div>
      </el-form-item>
      <el-form-item label="提交试卷时间：" prop="topicScore">
        <div>{{examinationRecordData.memberFinishTime | glbTimeFormat}}</div>
      </el-form-item>
      <el-form-item label="得分：" prop="topicScore">
        <div>{{examinationRecordData.topicScore}}</div>
      </el-form-item>
      <el-form-item label="正确题数：" prop="topicCount">
        <div>{{examinationRecordData.rightCount}}</div>
        <!-- <div>{{examinationRecordData.rightCount + '/' + examinationRecordData.topicCount}}</div> -->
      </el-form-item>
      <el-form-item label="题目：" prop="examinationTopicList">
        <div v-if="examinationTopicList.length <= 0" style="color:rgb(96, 98, 102);">未提交答案</div>
        <div v-else style="color:rgb(96, 98, 102);">
          <div v-for="(item, index) in examinationTopicList" :key="item.id">
            <div class="topic-title">
              {{index + 1 + "、"}}{{item.title}} &nbsp;&nbsp;
            </div>

            <div class="answer">
              <div class="member-answers">
                <span v-if="item.memberAnswer === item.rightAnswer">
                  <i style="color:#67C23A;font-weight: bold;margin-right: 5px;" class="el-icon-check"></i>
                </span>
                <span v-else>
                  <i style="color:#F56C6C;font-weight: bold;margin-right: 5px;" class="el-icon-close"></i>
                </span>
                <span>{{item.type === 3 ? '您的': '所选'}}答案：</span>
                <span>{{dealMemberAnswers(item)}}</span>
              </div>
              <div class="right-answers">
                <span>正确答案：</span>
                <span>{{dealRightAnswers(item)}}</span>
              </div>
            </div>
            <div class="score">得分：{{item.memberAnswer === item.rightAnswer ? '+' + item.maxScore : '-' +
              item.maxScore}}</div>
          </div>
        </div>
      </el-form-item>

      <el-form-item>
        <el-button @click="handleResetForm('examineAnswerSheetForm')">返 回</el-button>
        <!-- <el-button type="primary" :loading="btnLoading" @click="handleSubmitForm('paperForm')">保 存</el-button> -->
      </el-form-item>
    </el-form>

  </div>
</template>

<script>

import { GetStudentExaminationDetail } from '@/api/train'
export default {
  name: 'examineAnswerSheet',
  components: {},
  data () {
    return {
      selectReg: 'select',
      formLoading: false,
      userExaminationId: '',
      examinationRecordData: {},
      rules: {},
      examinationTopicList: []
    }
  },
  props: {},
  watch: {},
  computed: {},
  mounted () {
    this.userExaminationId = this.$route.query.id
    this.getDetail()
  },
  methods: {
    getDetail () {
      this.formLoading = true
      GetStudentExaminationDetail(this.userExaminationId).then(res => {
        this.formLoading = false
        const data = res.data
        this.examinationRecordData = data.verbUserExaminationRecord
        this.examinationRecordData.title = data.title || ''
        this.examinationTopicList = data.verbUserExaminationTopicList
      }).catch(e => {
        this.formLoading = false
      })
    },
    // 表单返回
    handleResetForm (formName) {
      this.$router.go(-1)
    },
    dealMemberAnswers (val) {
      let str = ''
      if (val.type === '3' || val.type === 3) {
        str = val.memberAnswer
      } else {
        let memberAnswers = []
        if (val.memberAnswer) {
          memberAnswers = val.memberAnswer.split(',')
        }
        memberAnswers.forEach(item => {
          const selectKey = this.selectReg + item
          const itemSrt = item + '、' + val[selectKey] + ' '
          str += itemSrt
        })
      }

      return str
    },
    dealRightAnswers (val) {
      let str = ''
      if (val.type === '3' || val.type === 3) {
        str = val.rightAnswer
      } else {
        let rightAnswers = []
        if (val.rightAnswer) {
          rightAnswers = val.rightAnswer.split(',')
        }
        rightAnswers.forEach(item => {
          const selectKey = this.selectReg + item
          const itemSrt = item + '、' + val[selectKey] + ' '
          str += itemSrt
        })
      }

      return str
    }
  }
}

</script>
<style lang='scss' scoped>
</style>
